﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using System.Runtime.Serialization;
using DTO;
using DAO;

using System.Collections;
namespace WcfServiceLibrary{
	public class DataContext : IDataContext{
		private String m_constring;
		public void myString(string myconnecString) {
			this.m_constring = myconnecString;
		}
		
		#region Bill
		// 0.them moi ; 1 Sua , 2 Delete
		Bill billDto = null;
		public Boolean OnSubmit(ref Bill item,int t){
			BillDAO ctr = new BillDAO(this.m_constring);
		if(	ctr.OnSubmit(ref item,t)==1)
			return true;
			return false;
		}
		//Lay thong tin tat ca du lieu cua Bill
		
		public List<Bill> GetAllBill(){
			BillDAO t = new BillDAO(this.m_constring);
			return t.GetAll();
		}
		//Lay thong tin du lieu cua Bill theo id
		
		public Bill GetItemByIdBill(object id){
			BillDAO t = new BillDAO(this.m_constring);
			return t.GetItemById(id);
		}

       
        public void ShoppingCart(List<Monhang> list, Users item) { 

        }
		#endregion
		
		#region Billdetail
		// 0.them moi ; 1 Sua , 2 Delete
		Billdetail billdetailDto = null;
		public Boolean OnSubmit(Billdetail item,int t){
			BilldetailDAO ctr = new BilldetailDAO(this.m_constring);
		if(	ctr.OnSubmit(item,t)==1)
			return true;
			return false;
		}
		//Lay thong tin tat ca du lieu cua Billdetail
		
		public List<Billdetail> GetAllBilldetail(){
			BilldetailDAO t = new BilldetailDAO(this.m_constring);
			return t.GetAll();
		}
		//Lay thong tin du lieu cua Billdetail theo id
		
		public Billdetail GetItemByIdBilldetail(object id){
			BilldetailDAO t = new BilldetailDAO(this.m_constring);
			return t.GetItemById(id);
		}

        public List<Billdetail> getBillDetailByBillId(long billId) {
            BilldetailDAO t = new BilldetailDAO(this.m_constring);
            return t.getBillDetailByBillId(billId);
        }
		#endregion
		
		#region Cart
		// 0.them moi ; 1 Sua , 2 Delete
		Cart cartDto = null;
		public Boolean OnSubmit(ref Cart item,int t){
			CartDAO ctr = new CartDAO(this.m_constring);
		if(	ctr.OnSubmit(ref item,t)==1)
			return true;
			return false;
		}
		//Lay thong tin tat ca du lieu cua Cart
		
		public List<Cart> GetAllCart(){
			CartDAO t = new CartDAO(this.m_constring);
			return t.GetAll();
		}
		//Lay thong tin du lieu cua Cart theo id
		
		public Cart GetItemByIdCart(object id){
			CartDAO t = new CartDAO(this.m_constring);
			return t.GetItemById(id);
		}

        //Lay cart theo trang thai (0 chua giao,1 dang giao,2 da giao)
        public List<Cart> getCartsByStatus(int Status) {
            CartDAO t = new CartDAO(this.m_constring);
            return t.getCartsByStatus(Status);
        }

        public List<Cart> getCartByUsers(long customersId)
        {
            CartDAO t = new CartDAO(this.m_constring);
            return t.getCartByUsers(customersId);
        }
		#endregion
		
		#region Cartdetail
		// 0.them moi ; 1 Sua , 2 Delete
		Cartdetail cartdetailDto = null;
		public Boolean OnSubmit(Cartdetail item,int t){
			CartdetailDAO ctr = new CartdetailDAO(this.m_constring);
		if(	ctr.OnSubmit(item,t)==1)
			return true;
			return false;
		}
		//Lay thong tin tat ca du lieu cua Cartdetail
		
		public List<Cartdetail> GetAllCartdetail(){
			CartdetailDAO t = new CartdetailDAO(this.m_constring);
			return t.GetAll();
		}
		//Lay thong tin du lieu cua Cartdetail theo id
		
		public Cartdetail GetItemByIdCartdetail(object id){
			CartdetailDAO t = new CartdetailDAO(this.m_constring);
			return t.GetItemById(id);
		}
        public List<Cartdetail> GetAllByCartDetailByCartId(long cartId) {
            CartdetailDAO t = new CartdetailDAO(this.m_constring);
            return t.GetAllByCartDetailByCartId(cartId);
        }
		#endregion
		
		#region Category
		// 0.them moi ; 1 Sua , 2 Delete
		Category categoryDto = null;
		public Boolean OnSubmit(Category item,int t){
			CategoryDAO ctr = new CategoryDAO(this.m_constring);
		if(	ctr.OnSubmit(item,t)==1)
			return true;
			return false;
		}
		//Lay thong tin tat ca du lieu cua Category
		
		public List<Category> GetAllCategory(){
			CategoryDAO t = new CategoryDAO(this.m_constring);
			return t.GetAll();
		}
		//Lay thong tin du lieu cua Category theo id
		
		public Category GetItemByIdCategory(object id){
			CategoryDAO t = new CategoryDAO(this.m_constring);
			return t.GetItemById(id);
		}
		#endregion
		
		#region Customers
		// 0.them moi ; 1 Sua , 2 Delete
		Customers customersDto = null;
		public Boolean OnSubmit(Customers item,int t){
			CustomersDAO ctr = new CustomersDAO(this.m_constring);
		if(	ctr.OnSubmit(item,t)==1)
			return true;
			return false;
		}
		//Lay thong tin tat ca du lieu cua Customers
		
		public List<Customers> GetAllCustomers(){
			CustomersDAO t = new CustomersDAO(this.m_constring);
			return t.GetAll();
		}
		//Lay thong tin du lieu cua Customers theo id
		
		public Customers GetItemByIdCustomers(object id){
			CustomersDAO t = new CustomersDAO(this.m_constring);
			return t.GetItemById(id);
		}
		#endregion
		
		#region Diaryproducts
		// 0.them moi ; 1 Sua , 2 Delete
		Diaryproducts diaryproductsDto = null;
		public Boolean OnSubmit(Diaryproducts item,int t){
			DiaryproductsDAO ctr = new DiaryproductsDAO(this.m_constring);
		if(	ctr.OnSubmit(item,t)==1)
			return true;
			return false;
		}
		//Lay thong tin tat ca du lieu cua Diaryproducts
		
		public List<Diaryproducts> GetAllDiaryproducts(){
			DiaryproductsDAO t = new DiaryproductsDAO(this.m_constring);
			return t.GetAll();
		}
		//Lay thong tin du lieu cua Diaryproducts theo id
		
		public Diaryproducts GetItemByIdDiaryproducts(object id){
			DiaryproductsDAO t = new DiaryproductsDAO(this.m_constring);
			return t.GetItemById(id);
		}
		#endregion
		
		#region Foreigncurrency
		// 0.them moi ; 1 Sua , 2 Delete
		Foreigncurrency foreigncurrencyDto = null;
		public Boolean OnSubmit(Foreigncurrency item,int t){
			ForeigncurrencyDAO ctr = new ForeigncurrencyDAO(this.m_constring);
		if(	ctr.OnSubmit(item,t)==1)
			return true;
			return false;
		}
		//Lay thong tin tat ca du lieu cua Foreigncurrency
		
		public List<Foreigncurrency> GetAllForeigncurrency(){
			ForeigncurrencyDAO t = new ForeigncurrencyDAO(this.m_constring);
			return t.GetAll();
		}
		//Lay thong tin du lieu cua Foreigncurrency theo id
		
		public Foreigncurrency GetItemByIdForeigncurrency(object id){
			ForeigncurrencyDAO t = new ForeigncurrencyDAO(this.m_constring);
			return t.GetItemById(id);
		}
		#endregion
		
		#region Groupproducts
		// 0.them moi ; 1 Sua , 2 Delete
		Groupproducts groupproductsDto = null;
		public Boolean OnSubmit(Groupproducts item,int t){
			GroupproductsDAO ctr = new GroupproductsDAO(this.m_constring);
		if(	ctr.OnSubmit(item,t)==1)
			return true;
			return false;
		}
		//Lay thong tin tat ca du lieu cua Groupproducts
		
		public List<Groupproducts> GetAllGroupproducts(){
			GroupproductsDAO t = new GroupproductsDAO(this.m_constring);
			return t.GetAll();
		}

        public ArrayList GetAllAGroupproducts() {
            ArrayList list = new ArrayList();
            GroupproductsDAO t = new GroupproductsDAO(this.m_constring);
            foreach (Groupproducts g in t.GetAll()) {
                list.Add(g);
            }
            return list;
        }
		//Lay thong tin du lieu cua Groupproducts theo id
		
		public Groupproducts GetItemByIdGroupproducts(object id){
			GroupproductsDAO t = new GroupproductsDAO(this.m_constring);
			return t.GetItemById(id);
		}
		#endregion
		
		#region News
		// 0.them moi ; 1 Sua , 2 Delete
		News newsDto = null;
		public Boolean OnSubmit(News item,int t){
			NewsDAO ctr = new NewsDAO(this.m_constring);
		if(	ctr.OnSubmit(item,t)==1)
			return true;
			return false;
		}
		//Lay thong tin tat ca du lieu cua News
		
		public List<News> GetAllNews(){
			NewsDAO t = new NewsDAO(this.m_constring);
			return t.GetAll();
		}
		//Lay thong tin du lieu cua News theo id
		
		public News GetItemByIdNews(object id){
			NewsDAO t = new NewsDAO(this.m_constring);
			return t.GetItemById(id);
		}
		#endregion
		
		#region Products
		// 0.them moi ; 1 Sua , 2 Delete
		Products productsDto = null;
		public Boolean OnSubmit(Products item,int t){
			ProductsDAO ctr = new ProductsDAO(this.m_constring);
		if(	ctr.OnSubmit(item,t)==1)
			return true;
			return false;
		}
		//Lay thong tin tat ca du lieu cua Products
		
		public List<Products> GetAllProducts(){
			ProductsDAO t = new ProductsDAO(this.m_constring);
			return t.GetAll();
		}
		//Lay thong tin du lieu cua Products theo id
		
		public Products GetItemByIdProducts(object id){
			ProductsDAO t = new ProductsDAO(this.m_constring);
			return t.GetItemById(id);
		}
        public List<Products> GetProductsBygroupId(long id) {
            ProductsDAO t = new ProductsDAO(this.m_constring);
            return t.GetAllByGroupId(id);
        }
		#endregion
		
		#region Quangcao
		// 0.them moi ; 1 Sua , 2 Delete
		Quangcao quangcaoDto = null;
		public Boolean OnSubmit(Quangcao item,int t){
			QuangcaoDAO ctr = new QuangcaoDAO(this.m_constring);
		if(	ctr.OnSubmit(item,t)==1)
			return true;
			return false;
		}
		//Lay thong tin tat ca du lieu cua Quangcao
		
		public List<Quangcao> GetAllQuangcao(){
			QuangcaoDAO t = new QuangcaoDAO(this.m_constring);
			return t.GetAll();
		}
		//Lay thong tin du lieu cua Quangcao theo id
		
		public Quangcao GetItemByIdQuangcao(object id){
			QuangcaoDAO t = new QuangcaoDAO(this.m_constring);
			return t.GetItemById(id);
		}
		#endregion
		
		#region Usergroups
		// 0.them moi ; 1 Sua , 2 Delete
		Usergroups usergroupsDto = null;
		public Boolean OnSubmit(Usergroups item,int t){
			UsergroupsDAO ctr = new UsergroupsDAO(this.m_constring);
		if(	ctr.OnSubmit(item,t)==1)
			return true;
			return false;
		}
		//Lay thong tin tat ca du lieu cua Usergroups
		
		public List<Usergroups> GetAllUsergroups(){
			UsergroupsDAO t = new UsergroupsDAO(this.m_constring);
			return t.GetAll();
		}
		//Lay thong tin du lieu cua Usergroups theo id
		
		public Usergroups GetItemByIdUsergroups(object id){
			UsergroupsDAO t = new UsergroupsDAO(this.m_constring);
			return t.GetItemById(id);
		}
		#endregion
		
		#region Users
		// 0.them moi ; 1 Sua , 2 Delete
		Users usersDto = null;
		public Boolean OnSubmit(Users item,int t){
			UsersDAO ctr = new UsersDAO(this.m_constring);
		if(	ctr.OnSubmit(item,t)==1)
			return true;
			return false;
		}
		//Lay thong tin tat ca du lieu cua Users
		
		public List<Users> GetAllUsers(){
			UsersDAO t = new UsersDAO(this.m_constring);
			return t.GetAll();
		}
		//Lay thong tin du lieu cua Users theo id
		
		public Users GetItemByIdUsers(object id){
			UsersDAO t = new UsersDAO(this.m_constring);
			return t.GetItemById(id);
		}

        public Users login(String userName, String password) {
            UsersDAO t = new UsersDAO(this.m_constring);
            return t.logIn(userName,password);
        }
		#endregion
		
		#region Vendor
		// 0.them moi ; 1 Sua , 2 Delete
		Vendor vendorDto = null;
		public Boolean OnSubmit(Vendor item,int t){
			VendorDAO ctr = new VendorDAO(this.m_constring);
		if(	ctr.OnSubmit(item,t)==1)
			return true;
			return false;
		}
		//Lay thong tin tat ca du lieu cua Vendor
		
		public List<Vendor> GetAllVendor(){
			VendorDAO t = new VendorDAO(this.m_constring);
			return t.GetAll();
		}
		//Lay thong tin du lieu cua Vendor theo id
		
		public Vendor GetItemByIdVendor(object id){
			VendorDAO t = new VendorDAO(this.m_constring);
			return t.GetItemById(id);
		}
		#endregion

	}
}
